package xtable;

import com.goldhuman.Common.Marshal.OctetsStream;
import com.goldhuman.Common.Marshal.MarshalException;

public class _Tables_ extends xdb.Tables {
	static volatile boolean isExplicitLockCheck = false;

	public static void startExplicitLockCheck() {
		isExplicitLockCheck = true;
	}

	public static _Tables_ getInstance() {
		return (_Tables_)xdb.Xdb.getInstance().getTables();
	}

	public _Tables_() {
		add(localids);
		add(roles);
		add(token);
		add(user);
	}

	// visible in package
	xdb.TTable<Integer, xbean.ServerId> localids = new xdb.TTable<Integer, xbean.ServerId>() {
		@Override
		public String getName() {
			return "localids";
		}

		@Override
		public OctetsStream marshalKey(Integer key) {
			OctetsStream _os_ = new OctetsStream();
			_os_.marshal(key);
			return _os_;
		}

		@Override
		public OctetsStream marshalValue(xbean.ServerId value) {
			OctetsStream _os_ = new OctetsStream();
			value.marshal(_os_);
			return _os_;
		}

		@Override
		public Integer unmarshalKey(OctetsStream _os_) throws MarshalException {
			int key = 0;
			key = _os_.unmarshal_int();
			return key;
		}

		@Override
		public xbean.ServerId unmarshalValue(OctetsStream _os_) throws MarshalException {
			xbean.ServerId value = xbean.Pod.newServerId();
			value.unmarshal(_os_);
			return value;
		}

		@Override
		public xbean.ServerId newValue() {
			xbean.ServerId value = xbean.Pod.newServerId();
			return value;
		}

	};

	xdb.TTable<Long, xbean.Role> roles = new xdb.TTable<Long, xbean.Role>() {
		@Override
		public String getName() {
			return "roles";
		}

		@Override
		protected xdb.util.AutoKey<Long> bindAutoKey() {
			return getInstance().getTableSys().getAutoKeys().getAutoKeyLong(getName());
		}

		@Override
		public OctetsStream marshalKey(Long key) {
			OctetsStream _os_ = new OctetsStream();
			_os_.marshal(key);
			return _os_;
		}

		@Override
		public OctetsStream marshalValue(xbean.Role value) {
			OctetsStream _os_ = new OctetsStream();
			value.marshal(_os_);
			return _os_;
		}

		@Override
		public Long unmarshalKey(OctetsStream _os_) throws MarshalException {
			long key = 0;
			key = _os_.unmarshal_long();
			return key;
		}

		@Override
		public xbean.Role unmarshalValue(OctetsStream _os_) throws MarshalException {
			xbean.Role value = xbean.Pod.newRole();
			value.unmarshal(_os_);
			return value;
		}

		@Override
		public xbean.Role newValue() {
			xbean.Role value = xbean.Pod.newRole();
			return value;
		}

	};

	xdb.TTable<String, xbean.Token> token = new xdb.TTable<String, xbean.Token>() {
		@Override
		public String getName() {
			return "token";
		}

		@Override
		public OctetsStream marshalKey(String key) {
			OctetsStream _os_ = new OctetsStream();
			_os_.marshal(key, xdb.Const.IO_CHARSET);
			return _os_;
		}

		@Override
		public OctetsStream marshalValue(xbean.Token value) {
			OctetsStream _os_ = new OctetsStream();
			value.marshal(_os_);
			return _os_;
		}

		@Override
		public String unmarshalKey(OctetsStream _os_) throws MarshalException {
			String key = "";
			key = _os_.unmarshal_String(xdb.Const.IO_CHARSET);
			return key;
		}

		@Override
		public xbean.Token unmarshalValue(OctetsStream _os_) throws MarshalException {
			xbean.Token value = xbean.Pod.newToken();
			value.unmarshal(_os_);
			return value;
		}

		@Override
		public xbean.Token newValue() {
			xbean.Token value = xbean.Pod.newToken();
			return value;
		}

	};

	xdb.TTable<Long, xbean.User> user = new xdb.TTable<Long, xbean.User>() {
		@Override
		public String getName() {
			return "user";
		}

		@Override
		public OctetsStream marshalKey(Long key) {
			OctetsStream _os_ = new OctetsStream();
			_os_.marshal(key);
			return _os_;
		}

		@Override
		public OctetsStream marshalValue(xbean.User value) {
			OctetsStream _os_ = new OctetsStream();
			value.marshal(_os_);
			return _os_;
		}

		@Override
		public Long unmarshalKey(OctetsStream _os_) throws MarshalException {
			long key = 0;
			key = _os_.unmarshal_long();
			return key;
		}

		@Override
		public xbean.User unmarshalValue(OctetsStream _os_) throws MarshalException {
			xbean.User value = xbean.Pod.newUser();
			value.unmarshal(_os_);
			return value;
		}

		@Override
		public xbean.User newValue() {
			xbean.User value = xbean.Pod.newUser();
			return value;
		}

	};


}
